home *** CD-ROM | disk | FTP | other *** search
- (*===========================================================================*)
- (* Validate and build action blocks *)
- (* *)
- (* Copyright 1990, 1991, 1992 by H. Roy Engehausen. All rights reserved. *)
- (* *)
- (*===========================================================================*)
-
- (*=========================================================================*)
- (* Sub procedure to copy search blocks *)
- (*=========================================================================*)
-
- PROCEDURE copy_search_blocks;
-
- VAR
- i : WORD;
- n : search_block_ptr;
- s : search_block_ptr;
- o : search_block_ptr;
-
- BEGIN;
-
- (*---------------------------------------------------------------------*)
- (* Initialize for loop *)
- (*---------------------------------------------------------------------*)
-
- s := @search_info;
- o := NIL;
-
- (*---------------------------------------------------------------------*)
- (* Loop for each block *)
- (*---------------------------------------------------------------------*)
-
- REPEAT
-
- (*-------------------------------------------------------------------*)
- (* Test things *)
- (*-------------------------------------------------------------------*)
-
- {$IFDEF POINT_CHK}
- test_pointer(s);
- {$ENDIF}
-
- i := length_search_block(s);
- GETMEM(n, i);
- MOVE(s^, n^, i);
-
- IF o = NIL THEN
- new_msg_action^.action_srch := n
- ELSE
- o^.search_next := n;
-
- o := n;
- s := s^.search_next;
-
- UNTIL s = NIL;
-
- free_task_mem(search_memory_block_id, TRUE);
-
- END;
-
- (*=========================================================================*)
- (* Sub procedure to build an action block in memory for operations of *)
- (* the format "action search". Note that the caller must still initialize *)
- (* the action type *)
- (*=========================================================================*)
-
- PROCEDURE build_format0_block;
-
- VAR i : WORD;
-
- BEGIN;
-
- (*---------------------------------------------------------------------*)
- (* Get the search string *)
- (*---------------------------------------------------------------------*)
-
- s1 := subword(@s1, 2, 0);
-
- (*---------------------------------------------------------------------*)
- (* If its missing then give error *)
- (*---------------------------------------------------------------------*)
-
- IF s1 = '' THEN
- BEGIN;
- send_tnc_data_str('No search in action file -- ' + s1 + cr);
- active_tcb^.error_sw := TRUE;
- EXIT;
- END;
-
- (*---------------------------------------------------------------------*)
- (* Test the search string *)
- (*---------------------------------------------------------------------*)
-
- test_search;
- IF active_tcb^.error_sw THEN
- EXIT;
-
- (*---------------------------------------------------------------------*)
- (* Build a new action block *)
- (*---------------------------------------------------------------------*)
-
- i := LENGTH(s1) + 1 + WORD(action_msg_overhead);
- GETMEM(new_msg_action, i);
- FILLCHAR(new_msg_action^, i, #0);
-
- {$IFDEF DEBUG3}
- trace_data('AC0', i , new_msg_action, s1);
- {$ENDIF}
-
- (*---------------------------------------------------------------------*)
- (* Initialize certain areas *)
- (*---------------------------------------------------------------------*)
-
- new_msg_action^.next_action := NIL;
- new_msg_action^.action_srch := NIL;
- new_msg_action^.action_info := s1;
-
- (*---------------------------------------------------------------------*)
- (* Initialize the type field *)
- (*---------------------------------------------------------------------*)
-
- IF invert_flag THEN
- new_msg_action^.action_type := action_msg_invert
- ELSE
- new_msg_action^.action_type := 0;
-
- (*---------------------------------------------------------------------*)
- (* Copy over the search info *)
- (*---------------------------------------------------------------------*)
-
- copy_search_blocks;
-
- (*---------------------------------------------------------------------*)
- (* Chain the block on the end of the list *)
- (*---------------------------------------------------------------------*)
-
- chain_action;
-
- END;
-
- (*=========================================================================*)
- (* Sub procedure to validate an action in the format of "action operand *)
- (* search". At the end s1 = search and s2 = operand. *)
- (*=========================================================================*)
-
- PROCEDURE validate_format1_statement;
-
- BEGIN;
-
- (*---------------------------------------------------------------*)
- (* Throw away the verb *)
- (*---------------------------------------------------------------*)
-
- s1 := subword(@s1, 2, 0);
-
- (*---------------------------------------------------------------*)
- (* Break the incoming line into two parts -- The search and *)
- (* the operand *)
- (*---------------------------------------------------------------*)
-
- s2 := subword(@s1, 1, 1);
- s1 := subword(@s1, 2, 0);
- strip_var(s1, 'B');
- strip_var(s2, 'B');
-
- (*---------------------------------------------------------------*)
- (* Validate *)
- (*---------------------------------------------------------------*)
-
- IF s2 = '' THEN
- BEGIN;
- send_tnc_data_str('There are no operands -- ' + s1 + cr);
- active_tcb^.error_sw := TRUE;
- EXIT;
- END;
-
- IF s1 = '' THEN
- BEGIN;
- send_tnc_data_str('No search in action file -- ' + s1 + cr);
- active_tcb^.error_sw := TRUE;
- EXIT;
- END;
-
- (*---------------------------------------------------------------*)
- (* Test the search string *)
- (*---------------------------------------------------------------*)
-
- test_search;
-
- (*---------------------------------------------------------------*)
- (* Now exit in all cases *)
- (*---------------------------------------------------------------*)
-
- EXIT;
-
- END;
-
- (*=========================================================================*)
- (* Sub procedure to build an action block in memory for operations of *)
- (* the format "action operand search" The operand is stored as a string *)
- (* following the search. Note that the caller must still initialize the *)
- (* action type *)
- (*=========================================================================*)
-
- PROCEDURE build_format1_block;
-
- VAR i : WORD;
-
- BEGIN;
-
- (*---------------------------------------------------------------------*)
- (* Validate the statement and leave if error *)
- (*---------------------------------------------------------------------*)
-
- validate_format1_statement;
- IF active_tcb^.error_sw THEN EXIT;
-
- (*---------------------------------------------------------------------*)
- (* Get memory for it *)
- (*---------------------------------------------------------------------*)
-
- i := LENGTH(s1) + WORD(LENGTH(s2)) + 2 + action_msg_overhead;
-
- GETMEM(new_msg_action, i);
- FILLCHAR(new_msg_action^, i, #0);
-
- {$IFDEF DEBUG3}
- trace_data('AC1', i , new_msg_action, s1);
- {$ENDIF}
-
- (*---------------------------------------------------------------------*)
- (* Load the parms *)
- (*---------------------------------------------------------------------*)
-
- new_msg_action^.next_action := NIL;
- new_msg_action^.action_srch := NIL;
- new_msg_action^.action_info := s1;
-
- str_ptr := ADDR(new_msg_action^.action_info[LENGTH(s1) + 1]);
- str_ptr^ := s2;
-
- (*---------------------------------------------------------------------*)
- (* Initialize the type field *)
- (*---------------------------------------------------------------------*)
-
- IF invert_flag THEN
- new_msg_action^.action_type := action_msg_invert
- ELSE
- new_msg_action^.action_type := 0;
-
- (*---------------------------------------------------------------------*)
- (* Copy over the search info *)
- (*---------------------------------------------------------------------*)
-
- copy_search_blocks;
-
- (*---------------------------------------------------------------------*)
- (* Chain the block on the end of the list *)
- (*---------------------------------------------------------------------*)
-
- chain_action;
-
- END;
-
- (*=========================================================================*)
- (* Sub procedure to build an action block in memory for operations of *)
- (* the format "action operand search" The operand is stored as a WORD *)
- (* following the search. Note that the caller must still initialize the *)
- (* action type *)
- (*=========================================================================*)
-
- PROCEDURE build_format2_block(low_num : WORD; hi_num : WORD);
-
- VAR
- code : INTEGER;
- i : WORD;
- num : WORD;
- w_ptr : ^WORD;
-
- BEGIN;
-
- (*---------------------------------------------------------------------*)
- (* Validate the statement and leave if error *)
- (*---------------------------------------------------------------------*)
-
- validate_format1_statement;
- IF active_tcb^.error_sw THEN EXIT;
-
- (*---------------------------------------------------------------------*)
- (* Now get the numberer *)
- (*---------------------------------------------------------------------*)
-
- IF (LENGTH(s2) > 5) THEN
- BEGIN;
- send_tnc_data_str('The numeric operand is too long -- ' + s2 + cr);
- active_tcb^.error_sw := TRUE;
- EXIT;
- END;
-
- IF s2[1] = '-' THEN
- BEGIN;
- send_tnc_data_str('The numeric operand cannot be negative -- '
- + s2 + cr);
- active_tcb^.error_sw := TRUE;
- EXIT;
- END;
-
- VAL(s2, num, code);
-
- IF code <> 0 THEN
- BEGIN;
- send_tnc_data_str('Invalid numeric operand -- '
- + s2 + cr);
- active_tcb^.error_sw := TRUE;
- EXIT;
- END;
-
- IF (num < low_num) OR (num > hi_num) THEN
- BEGIN;
- send_tnc_data_str('Numeric operand out of bounds -- '
- + s2 + cr);
- active_tcb^.error_sw := TRUE;
- EXIT;
- END;
-
- (*---------------------------------------------------------------------*)
- (* Get memory for it *)
- (*---------------------------------------------------------------------*)
-
- i := LENGTH(s1) + WORD(SIZEOF(WORD)) + 1 + action_msg_overhead;
-
- GETMEM(new_msg_action, i);
- FILLCHAR(new_msg_action^, i, #0);
-
- {$IFDEF DEBUG3}
- trace_data('AC2', i , new_msg_action, s1);
- {$ENDIF}
-
- (*---------------------------------------------------------------------*)
- (* Load the parms *)
- (*---------------------------------------------------------------------*)
-
- new_msg_action^.next_action := NIL;
- new_msg_action^.action_info := s1;
- new_msg_action^.action_srch := NIL;
-
- w_ptr := ADDR(new_msg_action^.action_info[LENGTH(s1) + 1]);
- w_ptr^ := num;
-
- (*---------------------------------------------------------------------*)
- (* Initialize the type field *)
- (*---------------------------------------------------------------------*)
-
- IF invert_flag THEN
- new_msg_action^.action_type := action_msg_invert
- ELSE
- new_msg_action^.action_type := 0;
-
- (*---------------------------------------------------------------------*)
- (* Copy over the search info *)
- (*---------------------------------------------------------------------*)
-
- copy_search_blocks;
-
- (*---------------------------------------------------------------------*)
- (* Chain the block on the end of the list *)
- (*---------------------------------------------------------------------*)
-
- chain_action;
-
- END;